#define CTF_FLAG_MODEL  (1279)

new
	CTF_FileDataKeys[2][16]=
	{
		"CTF_flag1",
		"CTF_flag2"
	},
	CtfFlag[2],
	Float:CtfPosF[2][3],
	CtfIcon;

script_Deathmatch_Pickup(playerid, pickupid)
{
	if(DMmode==DM_MODE_CTF)
	{
	    new
			tmpPlayerTeam=pTeam(playerid),
			tmpEnemyTeam=poTeam(playerid);

		if(pickupid == CtfFlag[tmpEnemyTeam])
		{
		    if(IsValidDynamicPickup(CtfFlag[tmpPlayerTeam]))
		    {
				if(!(bPlayerDeathmatchSettings[playerid]&HasFlag))
				{
					DestroyDynamicPickup(pickupid);
					bitTrue(bPlayerDeathmatchSettings[playerid], HasFlag);
					UpdateFlagIcons();

					ShowMsgBox(playerid, "Get the flag back to the ~n~~b~drop point!", 3000);
					GameMsgF(BLUE, "%s Has picked up the Raven flag!", GetName(playerid));
					GiveXP(playerid, 10, "Flag Picked Up");
				}
			}
			return 1;
		}
		else if(pickupid == CtfFlag[tmpPlayerTeam])
		{
			if(bPlayerDeathmatchSettings[playerid]&HasFlag)
			{
			    CtfFlag[tmpEnemyTeam]=CreateDynamicPickup(CTF_FLAG_MODEL, 1, CtfPosF[tmpEnemyTeam][0], CtfPosF[tmpEnemyTeam][1], CtfPosF[tmpEnemyTeam][2]);
				bitFalse(bPlayerDeathmatchSettings[playerid], HasFlag);
				TeamScore[Flags][tmpPlayerTeam]++;
				UpdateFlagIcons();
				TeamScoreUpdate();

				GameMsgF(BLUE, "%s "#C_ORANGE"Has Captured a Flag for the "#C_RED"%s"#C_ORANGE" team", GetName(playerid), TeamName[tmpPlayerTeam]);
				GiveXP(playerid, 30, "Flag Captured");
			}
			else ShowMsgBox(playerid, "~w~This is your flag, ~r~defend it!~n~~w~If you capture an enemy flag, ~b~drop it here!", 3000);
		}
	}
	return 1;
}

